package com.example.a84416.shiyan2;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterViewFlipper;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;

public class UC3 extends AppCompatActivity {

    private AdapterViewFlipper adapterViewFlipper;
    private int img[]=new int[]{R.mipmap.a,R.mipmap.b,R.mipmap.c,R.mipmap.d,R.mipmap.f};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc3);
        Button btn1 = (Button) findViewById(R.id.exit);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

                adapterViewFlipper=findViewById(R.id.lunbo);
                BaseAdapter adapter=new BaseAdapter() {
                    @Override
                    public int getCount() {
                        return img.length;
                    }

                    @Override
                    public Object getItem(int i) {
                        return img[i];
                    }

                    @Override
                    public long getItemId(int i) {
                        return i;
                    }

                    @Override
                    public View getView(int i, View view, ViewGroup viewGroup) {
                        ImageView imageView=new ImageView(UC3.this);
                        imageView.setImageResource(img[i]);
                        return imageView;
                    }
                };
                adapterViewFlipper.setAdapter(adapter);
                adapterViewFlipper.setFlipInterval(1000);
                adapterViewFlipper.setAutoStart(true);
            }

        }
